package com.sanjishu.enterlab.electricity.sale.service;

import com.sanjishu.enterlab.electricity.sale.domain.Message;
import com.sanjishu.enterlab.electricity.sale.mapper.MessageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class UserMessageService {

    @Autowired
    private MessageMapper messageMapper;

    public List<Message> findByUserId(Integer userId) {
        return messageMapper.findByUserId(userId);
    }

    public void createUserMessage(Integer userId, Integer companyId, Integer types, String content) {
        Message message = new Message();
        message.setUserId(userId);
        message.setCompanyId(companyId);
        message.setContent(content);
        message.setCreatedAt(new Date());
        message.setTypes(types);
        message.setStatus(Message.STATUS_NORMAL);
        messageMapper.insert(message);
    }
}
